Repository navigation
refactor: extracts contract client from hermes client - #21
Merged
Merged
Conversation
stalniy
force-pushed
the
refactor/contract-client
branch
from
August 6, 2026 04:35
c471357 to
8ddc032
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Hermes client by extracting chain/contract interaction into a dedicated ContractClientService, adds unordered transaction support with accurate gas simulation for unordered bodies, and restructures CLI command folders accordingly.
Changes:
- Extract contract execution/query logic out of
HermesClientintosrc/services/contract-client/contract-client.service.ts. - Add unordered-tx signing + unordered-body gas simulation via
SigningStargateClientService. - Restructure CLI command modules and update tests to match the new layout.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Simplifies PriceUpdateOptions now that chain details live in the contract client service. |
| src/services/hermes-client/hermes-client.ts | Refactors Hermes client to depend on an injected contract client and support ordered/unordered update flow. |
| src/services/hermes-client/hermes-client.test.ts | Adds new HermesClient tests, but currently contains broken import paths. |
| src/services/contract-client/contract-client.service.ts | New service encapsulating contract queries/executes and ordered/unordered update submission. |
| src/services/contract-client/contract-client.service.test.ts | Adds test coverage for ordered/unordered updates, caching, and admin operations. |
| src/price-update/price-update-unordered/price-update-unordered.ts | Removes old unordered updater implementation (replaced by ContractClientService + SigningStargateClientService). |
| src/price-update/price-update-unordered/price-update-unordered.test.ts | Removes old unordered updater tests. |
| src/price-update/price-update-ordered/price-update-ordered.ts | Removes old ordered updater implementation. |
| src/price-update/price-update-ordered/price-update-ordered.test.ts | Removes old ordered updater tests. |
| src/lib/signing-stargate-client/signing-stargate-client.service.ts | Adds unordered tx signer + raw unordered-body simulation for correct gas estimation. |
| src/lib/signing-stargate-client/signing-stargate-client.service.test.ts | Adds tests validating unordered signing, simulation behavior, and caching. |
| src/lib/caching/helpers/helpers.ts | Introduces memoizeAsync helper for sharing in-flight work and avoiding caching failures. |
| src/lib/caching/helpers/helpers.test.ts | Tests memoizeAsync success caching and rejection non-caching. |
| src/hermes-client.test.ts | Removes old root-level Hermes client tests (replaced by service-scoped tests). |
| src/cli.ts | Updates CLI imports to match restructured command folders. |
| src/cli-commands/command-config.ts | Updates config parsing to wire in ContractClientService, unordered TTL, and gas multiplier. |
| src/cli-commands/update-command/update-command.ts | Updates to synchronous createHermesClient creation style. |
| src/cli-commands/update-command/update-command.test.ts | Updates test to match new createHermesClient signature. |
| src/cli-commands/status-command/status-command.ts | Updates to synchronous createHermesClient creation style. |
| src/cli-commands/status-command/status-command.test.ts | Updates imports + sync factory usage. |
| src/cli-commands/query-command/query-command.ts | Switches query command to use createContractClient. |
| src/cli-commands/query-command/query-command.test.ts | Updates test but currently contains broken import paths. |
| src/cli-commands/daemon-command/daemon-command.ts | Updates instrumentation + CommandConfig imports for new folder layout. |
| src/cli-commands/daemon-command/daemon-command.test.ts | Updates test but currently contains broken imports for HermesClient/daemonCommand. |
| src/cli-commands/admin-update-fee/admin-update-fee.ts | Switches to createContractClient and updates validation import. |
| src/cli-commands/admin-update-fee/admin-update-fee.test.ts | Updates test but currently contains broken import paths. |
| src/cli-commands/admin-transfer/admin-transfer.ts | Switches to createContractClient and updates validation import. |
| src/cli-commands/admin-transfer/admin-transfer.test.ts | Updates test but currently contains broken import paths. |
| src/cli-commands/admin-refresh-params/admin-refresh-params.ts | Switches to createContractClient. |
| src/cli-commands/admin-refresh-params/admin-refresh-params.test.ts | Updates test but currently contains broken import paths. |
| package.json | Adds @faker-js/faker for tests (Node engine already pinned to v24). |
| package-lock.json | Locks @faker-js/faker dependency. |
Suppressed comments (7)
src/cli-commands/query-command/query-command.test.ts:4
- These imports use paths relative to src/cli-commands/query-command/, but the referenced modules live in src/services/* and src/cli-commands/command-config.ts. As written, they resolve to non-existent files and the tests won’t compile.
src/services/hermes-client/hermes-client.ts:38 - HermesConfig declares priceUpdateTxMethod/denom/gasPrice/gasMultiplier as required, but the implementation provides defaults via
??and call sites (including the new hermes-client test setup) omit some of them. This makes the type contract stricter than the actual runtime behavior and will cause compile errors for existing callers.
src/cli-commands/admin-update-fee/admin-update-fee.test.ts:4 - The test imports ContractClientService and CommandConfig via paths that don’t exist from this folder (they currently resolve under src/cli-commands/admin-update-fee/*). This will break the test build.
src/cli-commands/admin-transfer/admin-transfer.test.ts:4 - The test imports ContractClientService and CommandConfig using paths that don’t exist after the folder restructuring, so it won’t compile.
src/cli-commands/admin-refresh-params/admin-refresh-params.test.ts:4 - The test imports ContractClientService and CommandConfig using paths that don’t exist from this folder, which will break compilation.
src/cli-commands/daemon-command/daemon-command.test.ts:5 - These imports don’t match the new file layout: HermesClient now lives under src/services/hermes-client/, and daemonCommand is in the same directory as this test (not one level up). As written, the paths won’t resolve.
src/services/hermes-client/hermes-client.ts:342 ContractClient.disconnect()comes from ContractClientService and is async (returns a Promise). Instart()the Promise is currently ignored, so disconnect errors can become unhandled rejections and the RPC connection may not be closed before the method resolves.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 31 out of 32 changed files in this pull request and generated 1 comment.
Suppressed comments (7)
src/cli-commands/query-command/query-command.test.ts:5
- These imports use paths that don't exist after the folder restructure (they resolve to src/cli-commands/services/... and src/cli-commands/query-command/command-config.ts). This will break TypeScript compilation for the tests.
src/cli-commands/admin-transfer/admin-transfer.test.ts:5 - These imports use paths that don't exist after the folder restructure (they resolve to src/cli-commands/services/... and src/cli-commands/admin-transfer/command-config.ts). This will break TypeScript compilation for the tests.
src/services/hermes-client/hermes-client.ts:342 - Contract client disconnect() returns a Promise, but start() does not await it. That can leave the RPC connection closing in the background (and can surface as an unhandled rejection if disconnect ever throws).
src/services/hermes-client/hermes-client.ts:39 - HermesConfig marks priceUpdateTxMethod/denom/gasPrice/gasMultiplier as required, but HermesClient applies defaults for each (and current tests construct HermesClient without them). This makes the public config type inconsistent with runtime behavior and will force callers to provide values that are effectively optional.
src/cli-commands/admin-update-fee/admin-update-fee.test.ts:5 - These imports use paths that don't exist after the folder restructure (they resolve to src/cli-commands/services/... and src/cli-commands/admin-update-fee/command-config.ts). This will break TypeScript compilation for the tests.
src/cli-commands/admin-refresh-params/admin-refresh-params.test.ts:5 - These imports use paths that don't exist after the folder restructure (they resolve to src/cli-commands/services/... and src/cli-commands/admin-refresh-params/command-config.ts). This will break TypeScript compilation for the tests.
src/cli-commands/update-command/update-command.test.ts:21 - setup() constructs a config object using the post-refactor CommandConfig shape, but this test file still imports HermesClient/CommandConfig from the old locations at the top of the file. With the current folder restructure those paths won't resolve, so the test suite won't compile.
stalniy
force-pushed
the
refactor/contract-client
branch
from
August 6, 2026 05:00
8ddc032 to
89a3ce5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
closes CON-794
What